require(["common", "eventManager", "coAjax", "queryString", "href", "hash_routie", "WX", "jQuery.qrcode"], function(jSouper, eventManager, coAjax, QueryString, href, hash_routie, WX) {

	hash_routie.on("classify", function() {
		var qs = new QueryString(location.hash);
		var select_classify_main = qs.get("main") || App.get("$Cache.classify.tree.childs")[0].classify._id;
		var vertical_classify = qs.get("vertical");
		// 获取选定主分类下的子分类
		var $main_dtd = new $.Deferred();

		function _get_main_classify(maindtd) {
			coAjax.get(appConfig.bus_classify_by_id + select_classify_main, {
				bus_id: appConfig.bus_id
			}, function(main) {
				App.set("$Cache.classify.main", main.result);
				maindtd.resolve(main.result || []);
			});
			return maindtd;
		};
		$.when(_get_main_classify($main_dtd)).then(function(mainresult) {
			// 确定链接中是否有子分类ID，若没有，则使用选定主分类id获取商品
			vertical_classify = vertical_classify || (mainresult.child_classify_list.length ? mainresult.child_classify_list[0]._id : select_classify_main);
			App.set("$Cache.classify.get_goods_classify", vertical_classify);
			// 获取选定子分类下的所有商品
			coAjax.get(appConfig.bus_classify_all_child_goods_by_id + vertical_classify, {
				bus_id: appConfig.bus_id
			}, function(goods_list) {
				App.set("$Cache.classify.goods_list", goods_list.result);
			});
		});
	});
});